Cover the "mark_as_read" option.

Akinori MUSHA 10 years ago
parent
commit
3a48076902
1 changed files with 15 additions and 0 deletions
  1. 15 0
      spec/models/agents/imap_folder_agent_spec.rb

+ 15 - 0
spec/models/agents/imap_folder_agent_spec.rb

@@ -183,6 +183,21 @@ describe Agents::ImapFolderAgent do
183 183
           (seen[mail.uidvalidity] ||= []) << mail.uid
184 184
         }
185 185
       end
186
+
187
+      it 'should never mark mails as read unless mark_as_read is true' do
188
+        @mails.each { |mail|
189
+          stub(mail).mark_as_read.never
190
+        }
191
+        lambda { @checker.check }.should change { Event.count }.by(2)
192
+      end
193
+
194
+      it 'should mark mails as read if mark_as_read is true' do
195
+        @checker.options['mark_as_read'] = true
196
+        @mails.each { |mail|
197
+          stub(mail).mark_as_read.once
198
+        }
199
+        lambda { @checker.check }.should change { Event.count }.by(2)
200
+      end
186 201
     end
187 202
   end
188 203
 end